package fr.labri.macchiato.framework.technical.file;

/**
 * Class that defines a function that build a text file on the client side and
 * downloads it
 * 
 * @author Matthieu FOUCAULT
 * 
 */
public class FileSaver {

	
	/**
	 * Creates a text file with the given title and contents, and downloads it. <br>
	 * This is an HTML5 feature and may not work on every browser
	 * 
	 * @param title
	 * @param contents
	 */
	public static native void saveFile(String title, String contents) /*-{

		var bb = new $wnd.BlobBuilder();
		bb.append(contents);

		var blob = bb.getBlob();
		$wnd.saveAs(blob, title);

	}-*/;

}
